﻿using Programming.DemoProject.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Programming.DemoProject.AOP
{
    /// <summary>
    /// 既没有修改对象  也没有替换对象 但是增加了功能--AOP---静态AOP
    /// ----对，我是修改了proxy
    /// </summary>
    public class DBHelperProxy : IDBHelper
    {
        private IDBHelper _iDBHelper = new MySQLDBHelper();
        private ILogHelper helper = new LogConsole();

        private void Before()
        {
            this.helper.Log("Prepare Save");
        }

        public int Save(UserInfo userInfo)
        {
            this.Before();
            int iResult = this._iDBHelper.Save(userInfo);
            this.After();
            return iResult;
        }

        private void After()
        {
            this.helper.Log("After Save");
        }
    }
}
